﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJ.Framework.Common;
using PJ.Data.Inventory;

namespace PJ.Business.Inventory
{
    /// <summary>
    /// InventoryItemService class
    /// </summary>
    public class InventoryItemService : ItemService<IInventoryItem, IInventoryItemData, IInventoryItemProvider>, IInventoryItemService
    {
        #region Constructor
        /// <summary>
        /// Initialize
        /// </summary>
        /// <param name="dataService">Data provider</param>
        /// <param name="salesParamService">Sales parameters service</param>
        /// <param name="barcodeService">Bar code service</param>
        [Microsoft.Practices.Unity.InjectionConstructor]
        public InventoryItemService(IInventoryItemProvider dataService, IInventoryItemSalesParamService salesParamService, IInventoryBarCodeService barcodeService)
            : base(dataService)
        {
            if (salesParamService == null)
                throw new ArgumentNullException("salesParamService");
            if (barcodeService == null)
                throw new ArgumentNullException("barcodeService");
            _InventoryItemSalesParamService = salesParamService;
            _InventoryBarCodeService = barcodeService;
        }
        #endregion

        #region Interface implementation

        public IInventoryItemSalesParamService InventoryItemSalesParamService
        {get { return _InventoryItemSalesParamService; }}

        public IInventoryBarCodeService InventoryBarCodeService
        { get { return _InventoryBarCodeService; } }

        #endregion


        #region Public

        public override IInventoryItem CreateNewItem()
        {
            return new InventoryItem(DataService.CreateNewItem());
        }
        #endregion

        #region Field

        private IInventoryItemSalesParamService _InventoryItemSalesParamService;
        private IInventoryBarCodeService _InventoryBarCodeService;

        #endregion
    }
}
